﻿<!DOCTYPE html>
<html>
<head>
    <title>电子缴款</title>
    <#include "../inc/header.ftl"/>
    <link rel="stylesheet" href="${prefix}/assets/custom/css/main.css?20240428"/>
</head>
<body>

<div class="main-container ace-save-state" id="main-container">

    <div class="main-content">
        <div class="main-content-inner">

            <div class="page-content">
                <table width="900" border="0" align="center" cellpadding="0" cellspacing="0" class="r_tablebr">
                    <tr>
                        <td class="r_nr">
                            <table width="99%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td class="r_title">河北省非税收入电子缴款</td>
                                </tr>
                            </table>
                            <form name="eticketNumForm" id="eticketNumForm" action="queryEticketNumData" method="post">
                                <input name="filldate" type="hidden" id="filldate" value=""/>
                                <table width="99%" border="0" cellpadding="0" cellspacing="0" class="r_zsdwbm">
                                    <tr>
                                        <td width="30%">单位编码：
                                            <input name="agencycode" type="text" id="agencycode" readonly="readonly" value="" class="r_input" />          <label for="textfield"></label></td>
                                        <td align="right" colspan="2">缴款码：<input name="billnum" type="text" id="billnum" value="" class="r_input2" style="width:170px;" />
                                            &emsp;交易流水号：<input type="text" id="bankaffirm" name="bankaffirm" value="" class="r_input2" style="width:170px;"></td>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">单位名称：
                                            <input name="agencyname" type="text" id="agencyname" readonly="readonly" style="width:230px" value="" class="r_input" /></td>
                                        <td width="50%" align="center" class="r_zsdwbmwz">开票日期：<span id="filldateshow">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;
                                            过期日期：<span id="guoqidateshow"></span></td>
                                    </tr>
                                </table>
                                <table width="99%" border="1" cellpadding="0" cellspacing="1" class="r_jcxx2">
                                    <tr>
                                        <td width="15%" align="right">付款人全称</td>
                                        <td width="35%"><input name="payer" type="text" id="payer" readonly="readonly" style="width:95%" value="" /></td>
                                        <td width="15%" align="right">收款人全称</td>
                                        <td width="35%"><input name="payee" type="text" id="payee" readonly="readonly" style="width:95%" value="" /></td>
                                    </tr>
                                    <tr>
                                        <td align="right">付款人账号</td>
                                        <td><input type="text" name="payeraccount" id="payeraccount" readonly="readonly" value="" style="width:95%" /></td>
                                        <td width="15%" align="right">收款人账号</td>
                                        <td><input name="payeeaccount" type="text" id="payeeaccount" readonly="readonly" style="width:95%" value="" /></td>
                                    </tr>
                                    <tr>
                                        <td align="right">付款人开户银行</td>
                                        <td><input type="text" name="payerbank" id="payerbank" value="" readonly="readonly" style="width:95%" /></td>
                                        <td width="15%" align="right">收款人开户银行</td>
                                        <td><input name="payeebank" type="text" id="payeebank" style="width:95%" readonly="readonly" value="" /></td>
                                    </tr>
                                </table>


                                <div style="overflow-y: auto; height: 120px;border:1px solid #a0a0a0;margin-top:15px">
                                    <table width="100%" border="1" cellpadding="0" cellspacing="1" class="r_jcxx" id="tab" style="margin-top:-5px">
                                        <tr>
                                            <td width="10%" align="center">编码</td>
                                            <td width="40%" align="center">收入项目</td>
                                            <td width="10%" align="center">数量</td>
                                            <!--   <td width="20%" align="center">收缴标准</td>  -->
                                            <td width="10%" align="center">金额</td>
                                        </tr>
                                        <tbody>
                                        <tr id="tab-tr1">
                                            <td align="right">&nbsp;</td>
                                            <td>&nbsp;</td>
                                            <td width="15%" align="center">&nbsp;</td>
                                            <!--  <td align="center">&nbsp;</td> -->
                                            <td align="center">&nbsp;</td>
                                        </tr>
                                        <tr id="tab-tr2">
                                            <td align="right">&nbsp;</td>
                                            <td>&nbsp;</td>
                                            <td align="center">&nbsp;</td>
                                            <!-- <td align="center">&nbsp;</td> -->
                                            <td align="center">&nbsp;</td>
                                        </tr>
                                        <tr id="tab-tr3">
                                            <td align="right">&nbsp;</td>
                                            <td>&nbsp;</td>
                                            <td width="15%" align="center">&nbsp;</td>
                                            <!--  <td align="center">&nbsp;</td> -->
                                            <td align="center">&nbsp;</td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>


                                <table width="99%" border="0" cellpadding="0" cellspacing="0" class="r_zsdwbm">
                                    <tr>
                                        <td width="20%">
                                        </td>
                                        <td width="20%">付款方式：
                                            <label for="select"></label>
                                            <input name="payway" type="text" id="payway" class="r_input2" style="width:50%"/>
                                            </td>
                                        <td width="60%" align="right">金额（大写）：
                                            <input name="bigamt" type="text" id="bigamt" readonly="readonly" class="r_input" style="width:200px" value="" />
                                            （小写）：
                                            <input name="amt" type="text" id="amt" readonly="readonly" class="r_input" style="width:100px" value="" /></td>
                                    </tr>
                                </table>
                            </form>
                            <table width="99%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td height="40" align="right" style="padding: 20px 0 10px;">
                                        <input type="button" name="button" id="button" class="r_button" onclick="queryEticketNumData()" value="查询单据" />&emsp;
                                        <input type="button" name="paybutton" id="paybutton"  class="r_button" onclick="pay()" value="收款" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div><!-- /.page-content -->

        </div>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<#include "../inc/basicjs.ftl"/>
<!-- basic scripts -->
<script src="${prefix}/assets/custom/js/commonview.js"></script>

<script type="text/javascript">
    var ischeck = false;
    jQuery(function($) {
        //缴款方式下拉框
        $('#payway').combobox({
            data: _paywaydata,
            valueField:'paywayid',
            textField:'paywayname',
            panelHeight:'auto',
            onLoadSuccess:function(){
                var data = $('#paywaycode').combobox('getData');//获取所有下拉框数据
                if (data.length > 0) {
                    //如果有数据的话默认选中第一条数据
                    $('#paywaycode').combobox('select',data[0].paywayid);
                }
            }
        });
    })
    //数据初始化
    function pay() {
        if(!ischeck) {
            $.messager.alert('提示', "请先输入缴费编码，然后查询单据后再点击收款！", 'info');
            $("#billnum").focus();
            ischeck = false;
            return;
        }

        if($("#bankaffirm").val()=="") {
            $.messager.alert('提示', '请填写交易流水号！', 'info');
            return false;
        }
        if($("#payway").val()=="") {
            $.messager.alert('提示', '请选择付款方式！', 'info');
            return false;
        }

        $('#paybutton').attr('disabled',"true");//添加disabled属性


        $('#eticketNumForm').form({
            url: prefix + '/view/eticket/eticketNumpayview',
            onSubmit:function(){
                var isValid = $(this).form('validate');
                if (isValid){
                    $.messager.progress({
                        title: '提示',
                        msg: '数据处理中，请稍候……',
                        text: ''
                    });
                }
                return isValid;
            },
            success:function(data) {
                $.messager.progress('close');
                var data = eval('(' + data + ')');
                if(data.success) {
                    ischeck = false;
                    $.messager.alert('提示', data.msg, 'info', function() {
                        location=prefix+'/view/eticket/eticketnumview';
                    });
                } else {
                    $('#paybutton').removeAttr("disabled");// 移除disabled属性
                    $.messager.alert('提示', "【" + data.code + "】" + data.msg, 'info');
                }

            }
        });
        $('#eticketNumForm').submit();

    }
    function queryEticketNumData() {
        var state = [{"key":"0","value":"未知错误"},{"key":"1","value":"正常"},{"key":"2","value":"账户类型不符"},{"key":"3","value":"已收款"},{"key":"4","value":"票据不存在"},{"key":"5","value":"对账不成功，账户停用"},{"key":"6","value":"验签未通过"},{"key":"7","value":"该票据已超期"}];
        var billnum = $("#billnum").val();
        if(billnum==""){
            $.messager.alert('提示', '请输入缴款码！', 'info');
            $("#billnum").focus();
            return;
        }
        $.messager.progress({
            title: '提示',
            msg: '正在获取票据，请稍候……',
            text: ''
        });
        $.ajax({
            type: "POST",
            url: prefix + '/view/eticket/eticketNumData',
            dataType: "json",
            data: { billnum: billnum},
            success: function (dataOne) {
                $.messager.progress('close');
                if (!dataOne.success) {
                    $.messager.alert('提示', dataOne.msg, 'info');
                    return;
                }
                var bill = dataOne.data;
                if (bill.billstate == 3 || bill.billstate == 1) {
                    $("#agencycode").val(bill.agencycode);
                    $("#agencyname").val(bill.agencyname);
                    $("#amt").val(bill.amt);
                    $("#bigamt").val(upDigit(bill.amt));
                    $("#billnum").val(bill.billnum);
                    $("#payer").val(bill.payer);
                    $("#payee").val(bill.payee);
                    $("#payeraccount").val(bill.payeraccount);
                    $("#payeeaccount").val(bill.payeeaccount);
                    $("#payerbank").val(bill.payerbank);
                    $("#payeebank").val(bill.payeebank);
                    $("#vertifycode").val(bill.vertifycode);
                    var filldate = bill.filldate;
                    $("#filldateshow").html(filldate);
                    $("#guoqidateshow").html(dateCount(filldate,10));

                    var dataItem=$.parseJSON(bill.payinfo);

                    $("#tab tr:gt(0)").remove();
                    for(var p in dataItem){//遍历json数组时，这么写p为索引，0,1

                        //	alert( dataItem[p].incitemcode+ " " + dataItem[p].incitemname+ " " + dataItem[p].amount+ " " + dataItem[p].amt);
                        var tr1= '<tr><td align="center">'+dataItem[p].incitemcode+'</td><td>'+dataItem[p].incitemname+'</td><td width="15%" align="center">'+dataItem[p].amount+'</td><td align="center">'+dataItem[p].amt+'</td></tr>';

                        $('#tab').append(tr1);

                    }
                } 
                if (bill.billstate == 1) {
                    $('#paybutton').attr('disabled',false);
                    $('#billnum').attr("readonly","readonly");
                    ischeck = true;
                } else {
                    $('#paybutton').attr('disabled',true);
                    $.messager.alert('提示', dataOne.msgExt, 'info');
                } 
            }

        })
    }

</script>

</body>
</html>